home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / perl419x.zip / EG / CRLF.BAT next >
DOS Batch File  |  1992-02-23  |  920b  |  35 lines

  1. @REM=("
  2. @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  3. @end ") if 0 ;
  4.  
  5. # Convert all the files in the current directory from unix to MS-DOS
  6. # line ending conventions.
  7. #
  8. # By Diomidis Spinellis
  9. #
  10. open(FILES, 'find . -print |');
  11. while ($file = <FILES>) {
  12.     $file =^ s/[\n\r]//;
  13.     if (-f $file) {
  14.         if (-B $file) {
  15.             print STDERR "Skipping binary file $file\n";
  16.             next;
  17.         }
  18.         ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime,
  19.  $blksize, $blocks) = stat($file);
  20.         open(IFILE, "$file");
  21.         open(OFILE, ">xl$$");
  22.         while (<IFILE>) {
  23.             print OFILE;
  24.         }
  25.         close(OFILE) || die "close xl$$: $!\n";
  26.         close(IFILE) || die "close $file: $!\n";
  27.         unlink($file) || die "unlink $file: $!\n";
  28.         rename("xl$$", $file) || die "rename(xl$$, $file): $!\n";
  29.         chmod($mode, $file) || die "chmod($mode, $file: $!\n";
  30.         utime($atime, $mtime, $file) || die "utime($atime, $mtime, $file): $!\n";
  31.     }
  32. }
  33. @REM=(qq!
  34. :end !) if 0 ;
  35.